Getting started with the SDK

Some .NET C# code examples are provided to demonstrate the capabilities of the .NET Blueprint SDK, available as part of the Action Object Toolkit.

See also the complete reference of the Objects and Methods available in this help file.

Setting up Visual Studio

The code examples provided have been produced in Microsoft Visual Studio.  

When setting up your Visual Studio project, the following project configuration must be applied:

  1. Add the Action Object Toolkit SDK dll's as assembly references to your project. The SDK dll’s can be found in the Proficy CSense installation folder.

    • Proficy.CSense.SDK.dll

    • Proficy.CSense.SDK.Base.dll

    • Proficy.CSense.SDK.Blocks.dll

    • Proficy.CSense.SDK.Runtime

  2. Set the "Copy Local" option to false on all assemblies referred to above.

  3. Ensure that your source code is “using” the Proficy.CSense.SDK and Proficy.CSense.SDK.Blocks namespaces.
    NOTE: This information is typically added as a “using Proficy.CSense.SDK;” block at the top of your source file.

  4. Set your the "Platform Target" to x86.  Ensure that it is NOT set to “Any CPU”.

  5. Add an app.config file to your project with the contents provided in the following section.

App.Config file contents

Add an app.config file to your project and merge the existing file contents with the following:

XML:

<?xml version="1.0"?>
  <configuration>
   <startup>
       <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
   </startup>
  </configuration>

Deployment considerations

The following deployment scenarios should be considered for custom applications that make use of the Action Object Toolkit .

  • Basic: If your application is a single executable it can simply be placed in the CSense installation directory. Using the default CSense installation options this will be: <C:\Program Files (x86)\Proficy\Proficy CSense>.
  • Advanced: If your application has its own installer or is required to be in a separate location you must use, and implement a custom assembly resolver in your application. This is needed to redirect assembly resolving so that assemblies can be loaded from the CSense installation directory. Copying Action Object Toolkit assemblies to other locations is not supported. The "Copy Local" option must be set to false on the Action Object Toolkit assembly references. A C# example of how to implement a custom assembly resolver is shown bellow, assuming that CSense is installed in the default location <C:\Program Files (x86)\Proficy\Proficy CSense>.

 

C#:

using Proficy.CSense.SDK;
using System;
using System.Reflection;

namespace SDKTestApp

{
    class Program
   {
       static private String CSenseInstallationDirectory = @"C:\Program Files (x86)\Proficy\Proficy CSense\";

        static Assembly AssemblyResolver(Object sender, ResolveEventArgs args)
       {
           // Get the name of the assembly to load
           int index = args.Name.IndexOf(",");
           String name = args.Name.Substring(0, index);
           String fileName = CSenseInstallationDirectory + name + ".dll";
           if (System.IO.File.Exists(fileName))
           {
               return System.Reflection.Assembly.LoadFrom(fileName);
           }

            return null;
       }

        static void Main(string[] args)
       {
           // Using a deferred method to call CSense SDK code so that the AssemblyResolve
           // event handler will be fired, since all assemblies must be loaded first and
           // available for the code in any method to start execution.
           AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(AssemblyResolver);
           RunProgram(args);
       }

        static void RunProgram(string[] args)
       {
           try
           {
               // Code using the CSense SDK
               ActionObjectServer server = new ActionObjectServer();
               server.Refresh(ActionObjectKind.Realtime);
               var realtime = server.RealtimeActionObjects;
               System.Console.WriteLine("Found <" + realtime.Count.ToString() + "> deployed real-time Action Objects.");
           }
           catch (Exception exception)
           {
               System.Console.WriteLine(exception.Message);
           }
       }
}

    

 


Related topics:

  

CSense 2023- Last updated: June 24,2025